//
//  OCDistributorProduct.swift
//  OCDistributor
//
//  Created by Sam Chen on 2019/12/11.
//

/// 分销商品
public struct OCDistributorProduct: Codable {
    public let productId: Int
    public let name: String
    public let image: String

    /// 销售价
    public let price: Double
    public let priceFormat: String

    /// 原价
    public let originPrice: Double
    public let originPriceFormat: String

    /// 佣金
    public let commissions: [String]

    enum CodingKeys: String, CodingKey {
        case productId
        case name
        case image
        case price
        case priceFormat
        case originPrice
        case originPriceFormat
        case commissions = "profits"
    }
}

public extension OCDistributorProduct {
    /// 是否有打折价?
    var hasDiscountPrice: Bool { price != originPrice }
}
